
set.seed(12345)
##################################
######### Models  ################
##################################

########### Litigation Time: Model 1 ##########

z.out1 <- zelig(Surv(total_days, censored) ~ congress_required,model ="coxph", data=data2)
print(summary(z.out1), digits = 2)

0.23,        4.3, 0.087,      0.62,
NA, NA, NA, NA,
NA, NA, NA, NA,
NA, NA, NA, NA,
NA, NA, NA, NA,
NA, NA, NA, NA,
NA, NA, NA, NA,
NA, NA, NA, NA,
NA, NA, NA, NA

########### Litigation Time: Model 2 ##########

z.out1 <- zelig(Surv(total_days, censored) ~ congress_required+divided_government+cow_type1_dummy+usa_exports_ln+gdppc_ln+population_ln+polity2+trade_remedy_dummy,model ="coxph", data=data2)
print(summary(z.out1), digits = 2)


0.061,      16.45,     0.013,      0.28,
2.889,       0.35,     1.044,      7.99,
0.231,       4.33,     0.068,      0.79,
0.737,       1.36,     0.429,      1.27,
1.276,      0.78,     0.622,      2.62,
1.211,       0.83,     0.816,      1.80,
1.047,       0.95,     0.935,      1.17,
0.318,       3.14,     0.086,      1.17,
NA, NA, NA, NA

########### Litigation Time: Model 3 ##########

z.out1 <- zelig(Surv(total_days, censored) ~ congress_required++divided_government+cow_type1_dummy+usa_exports_ln+gdppc_ln+population_ln+polity2+trade_remedy_dummy+contribution_2010_ln,model ="coxph", data=data2)
print(summary(z.out1), digits = 2)

0.064,      15.52,     0.012,      0.35,
2.824,       0.35,     0.982,      8.12,
0.237,       4.23,     0.067,      0.84,
0.727,       1.38,     0.414,      1.28,
1.291,       0.77,     0.621,      2.68,
1.226,       0.82,     0.804,      1.87,
1.045,       0.96,     0.929,      1.17,
0.336,       2.97,     0.078,      1.45,
0.935,       1.07,     0.415,      2.11





##################################
######### Graphing ################
##################################

m <- 3 ######## Number of Tables
n <-9 ######## Number of Variables


par(mfrow=c(1,m), family = "serif",oma = c(2,11,4,1),mar = c(4,1,4,1))

######### Model 1 ################

vnames <- c("Congress Required", "Divided Government", "Formal Alliance", "USA Exports","GDP Per Capita", "Population", "Polity Score", "Trade Remedy Case", "Contributions")

vals <- c(
0.23,        4.3, 0.087,      0.62,
NA, NA, NA, NA,
NA, NA, NA, NA,
NA, NA, NA, NA,
NA, NA, NA, NA,
NA, NA, NA, NA,
NA, NA, NA, NA,
NA, NA, NA, NA,
NA, NA, NA, NA
)

plot(NULL, col = "grey10",xlim = c(0,3), ylim = c(.7, (n+.4)),  axes = F, xlab = NA, ylab = NA, xaxs = "i", yaxs = "i")

polygon(c(-0.015, 3.015, 3.015, -0.015), c(.7,.7,(n+.4),(n+.4)), border = "grey", col = "grey", xpd=NA)
y.axis <- c(n:1)
axis(2, at= y.axis, labels=vnames, las = 1, tick = T, ,mgp = c(2,.6,0), cex.axis = 1.2)
#text(-1, .7, "-1", pos = 1, xpd = T, cex = .8)
text(1, .7, "1.0", pos = 1, xpd = T, cex = .8)
text(3, .7, "3.0", pos = 1, xpd = T, cex = .8)
#text(1, .7, "1", pos = 1, xpd = T, cex = .8)
abline(v = 1, lty = 3, col = "white")
abline(v = 0, col = "white", lwd = 1)

fd <- matrix(nrow=n, ncol =4, vals, byrow=T)
for(i in 1:n){
	if(!is.na(fd[i,3])&fd[i,3] <1 &fd[i,4] > 1){
		mypch <-21
	} else { mypch <-19
		}		
			if(!is.na(fd[i,3])&fd[i,3] <1 &fd[i,4] > 1){
		myline <-2
	} else { myline <-1
		} 
		lines(c(fd[i,3], fd[i,4]), c(((n+1)-i),((n+1)-i)), lwd=3, lty=myline)
		points(fd[i,1],((n+1)-i),pch = mypch, cex =.5, bg="white")
}
mtext(side = 1, expression(paste("Hazard")), line = 1.2, cex = .8)
mtext(side = 3, "Model 1\nTotal Time\n(n = 37)", line = 1, cex = .9)

######### Model 2 ################


vals <- c(
0.061,      16.45,     0.013,      0.28,
2.889,       0.35,     1.044,      7.99,
0.231,       4.33,     0.068,      0.79,
0.737,       1.36,     0.429,      1.27,
1.276,      0.78,     0.622,      2.62,
1.211,       0.83,     0.816,      1.80,
1.047,       0.95,     0.935,      1.17,
0.318,       3.14,     0.086,      1.17,
NA, NA, NA, NA
)

plot(NULL, col = "grey10",xlim = c(0,3), ylim = c(.7, (n+.4)),  axes = F, xlab = NA, ylab = NA, xaxs = "i", yaxs = "i")

polygon(c(-0.015, 3.015, 3.015, -0.015), c(.7,.7,(n+.4),(n+.4)), border = "grey", col = "grey", xpd=NA)
#text(-1, .7, "-1", pos = 1, xpd = T, cex = .8)
text(1, .7, "1.0", pos = 1, xpd = T, cex = .8)
text(3, .7, "3.0", pos = 1, xpd = T, cex = .8)
#text(1, .7, "1", pos = 1, xpd = T, cex = .8)
abline(v = 1, lty = 3, col = "white")
abline(v = 0, col = "white", lwd = 1)

fd <- matrix(nrow=n, ncol =4, vals, byrow=T)
for(i in 1:n){
	if(!is.na(fd[i,3])&fd[i,3] <1 &fd[i,4] > 1){
		mypch <-21
	} else { mypch <-19
		}		
			if(!is.na(fd[i,3])&fd[i,3] <1 &fd[i,4] > 1){
		myline <-2
	} else { myline <-1
		} 
		lines(c(fd[i,3], fd[i,4]), c(((n+1)-i),((n+1)-i)), lwd=3, lty=myline)
		points(fd[i,1],((n+1)-i),pch = mypch, cex =.5, bg="white")
}
mtext(side = 1, expression(paste("Hazard")), line = 1.2, cex = .8)
mtext(side = 3, "Model 2\nTotal Time\n(n = 37)", line = 1,  cex = .9)

######### Model 3 ################


vals <- c(
0.064,      15.52,     0.012,      0.35,
2.824,       0.35,     0.982,      8.12,
0.237,       4.23,     0.067,      0.84,
0.727,       1.38,     0.414,      1.28,
1.291,       0.77,     0.621,      2.68,
1.226,       0.82,     0.804,      1.87,
1.045,       0.96,     0.929,      1.17,
0.336,       2.97,     0.078,      1.45,
0.935,       1.07,     0.415,      2.11
)

plot(NULL, col = "grey10",xlim = c(0,3), ylim = c(.7, (n+.4)),  axes = F, xlab = NA, ylab = NA, xaxs = "i", yaxs = "i")

polygon(c(-0.015, 3.015, 3.015, -0.015), c(.7,.7,(n+.4),(n+.4)), border = "grey", col = "grey", xpd=NA)
#text(-1, .7, "-1", pos = 1, xpd = T, cex = .8)
text(1, .7, "1.0", pos = 1, xpd = T, cex = .8)
text(3, .7, "3.0", pos = 1, xpd = T, cex = .8)
#text(1, .7, "1", pos = 1, xpd = T, cex = .8)
abline(v = 1, lty = 3, col = "white")
abline(v = 0, col = "white", lwd = 1)

fd <- matrix(nrow=n, ncol =4, vals, byrow=T)
for(i in 1:n){
	if(!is.na(fd[i,3])&fd[i,3] <1 &fd[i,4] > 1){
		mypch <-21
	} else { mypch <-19
		}		
			if(!is.na(fd[i,3])&fd[i,3] <1 &fd[i,4] > 1){
		myline <-2
	} else { myline <-1
		} 
		lines(c(fd[i,3], fd[i,4]), c(((n+1)-i),((n+1)-i)), lwd=3, lty=myline)
		points(fd[i,1],((n+1)-i),pch = mypch, cex =.5, bg="white")
}
mtext(side = 1, expression(paste("Hazard")), line = 1.2, cex = .8)
mtext(side = 3, "Model 3\nTotal Time\n(n = 37)", line = 1,  cex = .9)


